import request from '@/utils/request'
import { getToken, setToken, removeToken } from '@/utils/auth'

const TokenKey = 'Admin-Token'
const file=new FormData();
// 获取背景图
export function loadBackgroundImage() {
  return request({
    url: '/home/image/getAllImages',
    method: 'Get',
    contentType: "application/json;charset=UTF-8",
    data: null,
  })
}

//获取主页信息
export function loadHomePageInformation() {
  return request({
    url: '/Home/Message/getHomeMessage',
    method: 'Get',
    contentType: "application/json;charset=UTF-8",
    data: null,
  })
}

//获取主页动态信息
export function getHomepageDynamicInformation() {
  return request({
    url: '/Home/Message/getHomeDynamic',
    method: 'Get',
    contentType: "application/json;charset=UTF-8",
    data: null,
  })
}

//上传动态图片
export function uploadDynamicPictureLeaflet(file) {
  const files = new FormData();
  files.append('file',file)
  return request({
    url: '/Home/Message/updetImage',
    method: 'post',
    headers: {
      'content-Type': 'multipart/form-data;charset=UTF-8',
       'Accept': 'application/json',
      'Authorization':'Bearer '+getToken()
    },
    data: files
  })
}
export function removeTokenhome() {
  return Cookies.remove(TokenKey)
}

